import Config from './config'
export default {
    mergeUrl(url, baseUrl) {
        var urlMer = Config.baseUrl
        if (Config.dev) {
            return urlMer + url
        } else {
            return url
        }
    },
    getPageHeight() {
        return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
    },
    getPageWidth() {
        return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
    },
    getImgPath(name) {
        console.log("namexxxxxxxxxxxxxxxxxxxxxxxxxxxxx:")
        if (!name) {
            return Config.iconPath + 'switch.png'
        }
        return Config.iconPath + name + '.png'
    },
    getCookie(name) {
        var arr
        var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
        if (arr = document.cookie.match(reg)) {
            return unescape(arr[2])
        } else {
            return null
        }
    },

    getUUID() {
        var s4 = function() {
            return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
        }
        return (s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4())
    },

    getNode(nodes, id) {
        for (var i = 0; i < nodes.length; i++) {
            if (id === nodes[i]['data']['id']) {
                return nodes[i]['data']
            }
        }
    },
    resetLine() {
        return {
            'width': 1,
            'target-arrow-shape': 'triangle',
            'line-color': '#70c3ea',
            'curve-style': 'haystack',
            'label': 'data(label)',
            'haystack-radius': 9,
            'target-arrow-color': '#70c3ea'
        }
    },
    selectLine() {
        return {
            'width': 1,
            'target-arrow-shape': 'triangle',
            'line-color': 'red',
            'curve-style': 'haystack',
            'label': 'data(label)',
            'haystack-radius': 9,
            'target-arrow-color': 'red'
        }
    }
}